import { _decorator, Component, Node, CCFloat } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('MoveBg')
export default class MoveBg extends Component {
    @property(Node)
    target: Node | null = null;
    @property(CCFloat)
    speed_x: number = 0;
    @property(CCFloat)
    speed_y: number = 0;
    @property(CCFloat)
    distance_x: number = 720;
    @property(CCFloat)
    distance_y: number = 720;
    start_x: number = 0;
    start_y: number = 0;
    tween = null;

    onLoad() {
        // if (!this.target) {
        // this.target = this.node;
        // }

        // this.start_x = this.target.x;
        // this.start_y = this.target.y;

        //        // this.StartTween();
    }
    update(dt: number): void {
        // this.target.x += this.speed_x * dt;
        // this.target.y += this.speed_y * dt;

        // if (this.target.x > this.start_x + this.distance_x) {
        // this.target.x = this.start_x;
        // }

        // if (this.target.x < this.start_x - this.distance_x) {
        // this.target.x = this.start_x;
        // }

        // if (this.target.y > this.start_y + this.distance_y) {
        // this.target.y = this.start_y;
        // }

        // if (this.target.y < this.start_y - this.distance_y) {
        // this.target.y = this.start_y;
        // }
    }
}